import request from '@/utils/request.js'
const api_name = '/portal/question'

//获取问答列表
export function getQuestion (page,limit,data) {
  return request({
    url: `${api_name}/${page}/${limit}`,
    method: 'get',
    params: data
  })
}

//获取问答标签列表
export function getQuestionTag () {
  return request({
    url: `${api_name}/tag`,
    method: 'get'
  })
}

//获取问答详情
export function getQuestionDetailById (id) {
  return request({
    url: `${api_name}/detail/${id}`,
    method: 'get'
  })
}

//获取相关推荐问答
export function getRecommendQuestion (id) {
  return request({
    url: `${api_name}/recommend/${id}`,
    method: 'get'
  })
}

//获取问答评论分页列表
export function getCommentPageList (page,limit,questionId) {
  return request({
    url: `${api_name}/comment/${page}/${limit}/${questionId}`,
    method: 'get'
  })
}

//问答回复/二级回复
export function saveComment (data) {
  return request({
    url: `${api_name}/comment`,
    method: 'post',
    data
  })
}

// 发布问题
export function saveQuestion (data) {
  return request({
    url: `${api_name}`,
    method: 'post',
    data
  })
}

// 获取用户提问分页列表
export function getUserQuestionPageList (page,limit,userId) {
  return request({
    url: `${api_name}/user/${page}/${limit}/${userId}`,
    method: 'get'
  })
}

// 获取用户回复分页列表
export function getUserCommentPageList (page,limit,userId) {
  return request({
    url: `${api_name}/comment/user/${page}/${limit}/${userId}`,
    method: 'get'
  })
}

// 采纳最佳答案
export function updateCommentBest (data) {
  return request({
    url: `${api_name}/comment/best`,
    method: 'put',
    data
  })
}


//获取问答状态
export function getQuestionStatus (id) {
  return request({
    url: `${api_name}/${id}`,
    method: 'get',
  })
}
